package com.kqkj.dyrule.marketing.demo;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class RuleInjector {
    public static void main(String[] args) throws ClassNotFoundException, SQLException, IOException {
        String drlString = FileUtils.readFileToString(new File("rule_engine/src/main/resources/rules/demo1.drl"), "utf-8");

        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection conn = DriverManager.getConnection("jdbc:mysql://110.42.246.126:3306/gmall_flink?useUnicode=true&characterEncoding=utf8", "root", "123456");

        PreparedStatement st = conn.prepareStatement("insert into rule_demo (rule_name,drl_String,online) values (?,?,?)");
        st.setString(1,"demo1");
        st.setString(2,drlString);
        st.setString(3,"1");

        st.execute();
        st.close();
        conn.close();
    }
}
